 var idss = getvl("id");

 $(function(){
 	  if(idss!=''){
 	  	findmerchandise(idss);
 	  	//dingdan(orderId);
 	  }
 })
 function findmerchandise00(ids){
		$.ajax({
             url: urlcore + "/api/goods/findmerchandise?id="+ids,
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
			$("#goodsimg").attr("src",data.data.coverUrl);
			        var da=data.data;
			        if(da!=null && da!=''){
			        	$.each(da.goodsList,function(y,n){
			   var xiepingyu='<div class="quanju" >'+
			   '<div id="goodswrapper"><div class="pingjia_star">'+
			'<div class="starWrapper J-starWrapper star_on clearfix">'+
	            '<div class="clearfix fl">'+
	                '<span>商品评价</span>'+ 
	                '<img src="../images/star01.png" data-number="1" title="1.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="2" title="2.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="3" title="3.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="4" title="4.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="5" title="5.0分" data-bd-imgshare-binded="1">'+
	            '</div>'+
	            '<i>评分</i>'+ 
	            '<input type="hidden" name="sentiment_number" id="goodspingjia'+n.id+'" value="1">'+
	        '</div>'+
	        '<div class="starWrapper J-starWrapper star_on clearfix">'+
	            '<div class="clearfix fl">'+
	                '<span>满意度</span>'+ 
	                '<img src="../images/star01.png" data-number="3" title="1.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="2" title="2.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="1" title="3.0分" data-bd-imgshare-binded="1">'+
	            '</div>'+
	            '<i>评分</i>'+ 
	            '<input type="hidden" name="sentiment_number" id="manyidu'+n.id+'" value="1">'+
	            '<input type="hidden" id="shopinfoid'+n.id+'" value="'+n.shopId+'">'+
	        '</div>'+
        '</div>'+
			   '<div class="pingjia_dl">'+
            '<dl class="clearfix">'+
                '<dt>'+
                    '<img onerror="errorImg2(this)" src="'+n.coverUrl+'">'+
                '</dt>'+
                '<dd>'+
                    '<textarea id="pingyu'+n.id+'" placeholder="评价内容输入....."></textarea>'+
                '</dd>'+
            '</dl>'+
        '</div>'+
        '<div class="kaidian_dianpu" style="display: none;">'+
		'<div class="fabu_fengmian">'+
			'<div id="preview'+n.id+'">'+
	            '<img id="imghead'+n.id+'" border=0 src="../images/moren.jpg" />'+
	        '</div>'+
	        '<div class="fabu_file1"><input type="file" id="filess" /></div>'+
		'</div>'+
	'</div>'+
        '<div class="mm_imgfile'+n.id+'">'+
            '<ul class="clearfix">'+
                '<li>'+
                    '<img src="../images/moren.jpg">'+
                    '<input type="file"  onchange="previewImagenew(this,'+n.id+')">'+
                '</li>'+
            '</ul>'+
        '</div>'+
    '</div></div>'+
'<input type="button" value="提交评价"  onclick="tijiaopingjia('+n.id+')" />'+
             '</div>';
  /*            
                $(function(){
                	$('.mm_imgfile'+n.id+' input[type=file]').change(function(){
        var fs = this.files,$t  = $(this);
        $(fs).each(function(){
              var reader = new FileReader();
                reader.readAsDataURL(this);
                reader.onload = function(e) {
                    $t.parent().parent().prepend($('<li onclick="shanchu(this)"><input type="hidden"  class="classa" id="xijietu'+n.id+'"/><img src="'+this.result+'"></li>'));
                }
        });
    });
    
    function shanchu(te){
    	//删除
    	$(te).remove();
    	
    }
                });*/
               
                  $("#xiepingyu").append(xiepingyu);
         
		});
			}
			        
			
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});

 }
 /*
 function findmerchandise(goodsIds){
		$.ajax({
             url: urlcore + "/api/goods/findmerchandise?goodsId="+goodsIds,
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
			$("#goodsimg").attr("src",data.data.coverUrl);
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});

 }*/
 

 
 
function  tijiaopingjia(te){
	
	 $(".commentAlllist").each(function(){
	 	if($("#pingjialeirong"+$(this).attr("id")+"").val().length > 0 || $(".xijietu"+$(this).attr("id")+"").val().length>0){
	 
	  var te=$(this).attr("id");
	   var shopinfoid=$("#shopId"+$(this).attr("id")+"").val(); 
	  var wuliu=$("#wuliu"+$(this).attr("id")+"").val(); 
	  var shangpingpingfen=$("#GoodsId"+$(this).attr("id")+"").val(); 
	  var shopid=$(this).attr("name");	  
	   var xijie="";
	  $(".xijietu"+$(this).attr("id")+"").each(function(){
	    	  xijie+=$(this).val()+"***";
	    });
	     var xijietupian=xijie.substring(0,xijie.length-3);
	  
	 	  $.ajax({
	 	  	url: urlcore + "/api/comment/add",
	type: "post",
	contentType: "application/json;charset=utf-8",
	data: JSON.stringify({
		userId: uuuuid,
		qualityLevel: shangpingpingfen, // commentLevel:manyidu,好评 
		orderId: idss,
		serviceLevel: shopinfoid,
		carLevel: wuliu,
		shopId: shopid,
		goodsId: te,
		commentImg: xijietupian //图片没做
	}),
	dataType: "json",
	success: function(data) {
		if(data.success == true) {
			window.history.go(-1);
		} else if(data.code == 'OVERTIME') {
			var thisUrl = window.location.href;
			if(thisUrl.indexOf('login.html') <= -1) {
				top.window.location.href = "1.0.0denglu.html";
			}
		} else {
			alert(data.msg);
		}
	},
	error: function() {
		alert("error");
	}});
	 	
	 	}
	 
	 });
	  
	  
	 /// alert(quanju)
	  
	
}

/* var shangpingpingfen=$("#goodspingjia"+te).val();
	 var manyidu=$("#manyidu"+te).val();
	 var pingyu=$("#pingyu"+te).val();
	 var orderid=getvl("id");
	 var wuliu=$("#wuliufuwu").val();
	 var shopinfo=$("#shopinfo").val();
	 var shopinfoid=$("#shopinfoid"+te).val();
	 var tupian=$("#")
    $.ajax({
        url:  urlcore + "/api/comment/add",
        type: "post",
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify({
        	   userId:85,
        	   qualityLevel:shangpingpingfen,
        	   commentLevel:manyidu,
        	   orderId:orderid,
        	   serviceLevel:shopinfo,
        	   carLevel:wuliu,
        	   shopId:shopinfoid,
        	   goodsId:te                //图片没做
        }),
        dataType: "json",
        success:function(data){
            if (data.success == true) {
            	alert("评论成功");
            } else if (data.code == 'OVERTIME') {
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href = "1.0.0denglu.html";
                }
            } else {
                alert(data.msg);
            }
        },
        error: function() {
            alert("error");
        }
    });
*/




 function findmerchandise(ids){
		$.ajax({
             url: urlcore + "/api/goods/findmerchandise?id="+ids,
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
			        var da=data.data;
			        if(da!=null && da!=''){
			        	$.each(da.goodsList,function(y,n){
			        		var ds='<div class="pingjia_star commentAlllist" name="'+n.shopId+'" id="'+n.id+'">'+
		'<div class="starWrapper J-starWrapper star_on clearfix">'+
            '<div class="clearfix fl">'+
                '<span>商家服务</span>'+
                '<img src="../images/star01.png" data-number="1" title="1.0分" data-bd-imgshare-binded="1">'+
                '<img src="../images/star01.png" data-number="2" title="2.0分" data-bd-imgshare-binded="1">'+
                '<img src="../images/star01.png" data-number="3" title="3.0分" data-bd-imgshare-binded="1">'+
                '<img src="../images/star01.png" data-number="4" title="4.0分" data-bd-imgshare-binded="1">'+
                '<img src="../images/star01.png" data-number="5" title="5.0分" data-bd-imgshare-binded="1">'+
            '</div>'+
            '<i>评分</i>'+
            '<input type="hidden" name="sentiment_number" id="shopId'+n.id+'" value="1">'+
        '</div>'+
        '<div class="starWrapper J-starWrapper star_on clearfix" style="border-bottom: none;">'+
         '   <div class="clearfix fl">'+
          '      <span>物流服务</span> '+
           '     <img src="../images/star01.png" data-number="1" title="1.0分" data-bd-imgshare-binded="1">'+
            '    <img src="../images/star01.png" data-number="2" title="2.0分" data-bd-imgshare-binded="1">'+
             '   <img src="../images/star01.png" data-number="3" title="3.0分" data-bd-imgshare-binded="1">'+
              '  <img src="../images/star01.png" data-number="4" title="4.0分" data-bd-imgshare-binded="1">'+
               ' <img src="../images/star01.png" data-number="5" title="5.0分" data-bd-imgshare-binded="1">'+
            '</div>'+
            '<i>评分</i>'+ 
            '<input type="hidden" name="sentiment_number" id="wuliu'+n.id+'" value="1">'+
        '</div>'+
    '</div>'+
	'<div class="pingjia_text">'+
    '<div class="pingjia_star">'+
			'<div class="starWrapper J-starWrapper star_on clearfix">'+
	            '<div class="clearfix fl">'+
	             '   <span>商品评价</span> '+
	              '  <img src="../images/star01.png" data-number="1" title="1.0分" data-bd-imgshare-binded="1">'+
	               ' <img src="../images/star01.png" data-number="2" title="2.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="3" title="3.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="4" title="4.0分" data-bd-imgshare-binded="1">'+
	                '<img src="../images/star01.png" data-number="5" title="5.0分" data-bd-imgshare-binded="1">'+
	            '</div>'+
	            '<i>评分</i>'+
	            '<input type="hidden" name="sentiment_number" id="GoodsId'+n.id+'" value="1">'+
	        '</div>'+
        '</div>'+
        '<div class="pingjia_dl">'+
            '<dl class="clearfix">'+
                '<dt>'+
                    '<img src="'+n.coverUrl+'">'+
                '</dt>'+
                '<dd>'+
                 '   <textarea id="pingjialeirong'+n.id+'" placeholder="评价内容输入....."></textarea>'+
                '</dd>'+
            '</dl>'+
        '</div>'+
        '<div class="mm_imgfile">'+
        '<div class="kaidian_dianpu" style="display: none;">'+
		'<div class="fabu_fengmian">'+
			'<div id="preview22">'+
	            '<img id="imghead22" border=0 src="../images/moren.jpg" />'+
	        '</div>'+
	        '<div class="fabu_file1"><input type="file" id="filess"  /></div>'+
		'</div>'+
	'</div>'+
            '<ul class="clearfix">'+
               '<div id="pingluntupian'+n.id+'"><div>'+
               ' <li>'+
                    '<img src="../images/photo.png">'+
                    '<input type="file" id="'+n.id+'" onchange="previewImagenew(this)">'+
                '</li>'+
            '</ul>'+
        '</div>'+
    '</div>'+
    '<div class="pingjia_text">'+
    	'</div>'+
    	'</div>';
    	$("#xinxi").append(ds);
			        	});
			        	        $(function(){
			         	 jQuery(function(){//评分
        var imgSrc = '../images/star01.png'; 
        var imgSrc_2 = '../images/star.png'; 
        jQuery(".J-starWrapper").on('touchstart','img',function(){
            var $this = jQuery(this),
                index = $this.index(),
                $parent = jQuery(this).closest(".J-starWrapper");
            $parent.find("img").attr({"src":imgSrc});
            for(var i=0; i < index; ){
                $parent.find("img").eq(i).attr({"src":imgSrc_2});
                i++;
            }
        }).on('touchend',function(){
            var $this = jQuery(this);
            if(!$this.hasClass('star_on')){
                $this.find("img").attr({"src":imgSrc});
            }   
        }).on('click','img',function(){
            var $this = jQuery(this),
                num = $this.data('number'),
                title = $this.attr('title'),
                $parent = jQuery(this).closest(".J-starWrapper");
                $parent.find('i').html(title).css('color','#ffd700');
                $parent.addClass('star_on').find('input[type="hidden"]').val(num);
        }); 
    })
			      
/*			        	        
   $(".mm_imgfile input[type=file]").change(function(){
        var fs = this.files,$t  = $(this);
        $(fs).each(function(){
              var reader = new FileReader();
                reader.readAsDataURL(this);
                reader.onload = function(e) {/*<span data-name=delete></span>
                    $t.parent().parent().prepend($('<li><img src="'+this.result+'"><input type="text" id="xijietu"  class="xijietu"></li>'));
                  //  deleteImg();
                }
        });
    });*/
			        	        
			        	        });
                
			}
			        
			
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});

 }